package com.primaryedu.ui.center;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

import com.primaryedu.R;
import com.primaryedu.data.GlobalData;
import com.primaryedu.ui.BaseAppCompatActivity;
import com.primaryedu.ui.LoadActivity;
import com.primaryedu.ui.app.nicedialog.BaseNiceDialog;
import com.primaryedu.ui.app.nicedialog.DialogCallBackUtils;
import com.primaryedu.ui.app.nicedialog.DialogSureCallBack;
import com.primaryedu.ui.app.nicedialog.MyCustomDialog;

/**
 * 设置
 *
 * @author jun.wang
 * @description
 * @data 2016年12月15日
 */
public class SettingActivity extends BaseAppCompatActivity implements OnClickListener, DialogSureCallBack {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_setting);
        DialogCallBackUtils.setCallBack(this);
    }


    @Override
    protected int BindLayout() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initView() {
        DialogCallBackUtils.setCallBack(this);
        ((TextView) findViewById(R.id.title)).setText("设置");
        $(R.id.back).setOnClickListener(this);
//        $(R.id.next).setOnClickListener(this);
        $(R.id.text_clear).setOnClickListener(this);
        $(R.id.text_about).setOnClickListener(this);
        $(R.id.text_opinion).setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        Intent intent = null;

        switch (v.getId()) {
            case R.id.back:
                finish();
                break;

//            case R.id.next:

//                break;

            case R.id.text_clear:
                intent = new Intent(SettingActivity.this, ClearChcheActivity.class);
                startActivity(intent);
                break;

            case R.id.text_about:
                intent = new Intent(SettingActivity.this, AboutUsActivity.class);
                startActivity(intent);
                break;

            case R.id.text_opinion:
                intent = new Intent(SettingActivity.this, OpinionActivity.class);
                startActivity(intent);
                break;

            default:
                break;
        }
    }

    public void showdialogbackAccout(View view) {
        MyCustomDialog.newInstance("backAccout")
                .setMargin(60)
                .setOutCancel(false)
                .show(getSupportFragmentManager());

//        NiceDialog.init()
//                .setLayoutId(R.layout.cancel_layout)
//                .setConvertListener(new ViewConvertListener() {
//                    @Override
//                    protected void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
//                        holder.setOnClickListener(R.id.tv_one, new View.OnClickListener() {
//                            @Override
//                            public void onClick(View v) {
//                                showToast("相机");
//                                dialog.dismiss();
//                            }
//                        });
//                        holder.setOnClickListener(R.id.tv_two, new View.OnClickListener() {
//                            @Override
//                            public void onClick(View v) {
//                                showToast("相册");
//                                dialog.dismiss();
//                            }
//                        });
//                        holder.setOnClickListener(R.id.btn_bottom, new View.OnClickListener() {
//                            @Override
//                            public void onClick(View v) {
//                                dialog.dismiss();
//                            }
//                        });
//                    }
//                })
//                .setPosition(Gravity.BOTTOM)
//                .show(getSupportFragmentManager());
    }

    @Override
    public void SureClick(String type, BaseNiceDialog dialog) {
        if ("backAccout".equals(type)) {
            GlobalData.saveUserId(SettingActivity.this, "-1");
            Intent intent = new Intent(SettingActivity.this, LoadActivity.class);
            startActivity(intent);
            finish();
        }
        dialog.dismiss();
    }

    @Override
    protected void onResume() {
        super.onResume();
        DialogCallBackUtils.setCallBack(this);
    }
}
